﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Tank.Properties;

namespace Tank
{
    /// <summary>
    /// 助攻状态类
    /// </summary>
    public class Assist : GameElement
    {
        #region 助攻状态样式

        private static Image[] assistImg = {Resources.bomb,Resources.star2,Resources.timer };

        #endregion

        #region 构造助攻状态
        public Assist()
        {
        }
        public Assist(int x, int y, int no)
            :base(x,y,assistImg[0].Width,assistImg[0].Height)
        {
            this.No = no;
        }
        #endregion 

        #region 助攻状态效果

        /// <summary>
        /// 爆炸
        /// </summary>
        public void Bomb(List<Enemy> eTanks)
        {
            for (int i = 0; i < eTanks.Count; i++)
            {
                eTanks[i].Life = -1;//将敌人坦克集合中的坦克生命归零
            }
        }

        /// <summary>
        /// 定时器
        /// </summary>
        /// <param name="eTanks"></param>
        public void Timer(List<Enemy> eTanks)
        {
            int ti = DateTime.Now.Second;//实例化时间（秒）

            for (int i = 0; i < eTanks.Count; i++)
            {
                eTanks[i].Enable = false;//不可行动
            }
            do
            {
                if (ti <= 53)
                {
                    if (DateTime.Now.Second == ti + 6)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }              
                }
                else if (ti == 54)
                {
                    if (DateTime.Now.Second == 0)
                    {
                       for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 55)
                {
                    if (DateTime.Now.Second == 1)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 56)
                {
                    if (DateTime.Now.Second == 2)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 57)
                {
                    if (DateTime.Now.Second == 3)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 57)
                {
                    if (DateTime.Now.Second == 4)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 58)
                {
                    if (DateTime.Now.Second == 5)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
                else if (ti == 59)
                {
                    if (DateTime.Now.Second == 6)
                    {
                        for (int i = 0; i < eTanks.Count; i++)
                        {
                            eTanks[i].Enable = true;//不可行动
                        }
                        return;
                    }
                }
            } while (true);

        }

        /// <summary>
        /// 画出助攻状态样式
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            switch (No)
            {
                case 0:
                    g.DrawImage(assistImg[0], this.X, this.Y);
                    break;
                case 1:
                    g.DrawImage(assistImg[0], this.X, this.Y);
                    break;
                case 2:
                    g.DrawImage(assistImg[0], this.X, this.Y);
                    break;
                default:
                    break;
            }
        }

        #endregion

        #region 道具属性

        /// <summary>
        /// 助攻状态编号
        /// </summary>
        public int No { get; set; }

        /// <summary>
        /// 助攻状态名称
        /// </summary>
        public string Name { get; set; }

        #endregion


       
    }
}
